package org.spbsu.timetable.example;

import net.sourceforge.evoj.strategies.sorting.AbstractSimpleRating;

public class Rating extends AbstractSimpleRating<Solution> {

	public static double calcFunction(Solution solution) {
		double x = solution.getX();
		double y = solution.getY();
		return 12 * x * x + 8 * x + 9 * y * y;
	}

	/**
	 * Calculates the rating of the solution. The better solution - the bigger
	 * the returned Comparable should be.
	 */
	@Override
	public Comparable<?> doCalcRating(Solution solution) {
		double fn = calcFunction(solution);
		if (Double.isNaN(fn)) {
			return null;
		} else {
			return -fn;
		}
	}
}